<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:p="http://primefaces.org/ui"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets">
<ui:composition template="/pages/home.xhtml">
	<ui:define name="title">
		<h:outputText value="#{text.titBeneficio}" />
	</ui:define>
	<ui:define name="js">
		<h:outputScript name="jquery.meioMask.1.1.3.js" library="js"></h:outputScript>
	</ui:define>
	<ui:define name="content">
		<p:fieldset id="fieldSetBeneficio"
			binding="#{beneficioController.fieldSetBeneficio}">
			<h:inputHidden id="beneficioId"
				value="#{beneficioController.selectedBeneficio.idBeneficio}" />

			<h:panelGrid id="pnlFields" columns="3">

				<h:outputLabel for="socio" value="#{text.lblSocio}" />
				<h:panelGroup>
					<p:inputText id="socio" size="50" maxlength="30" readonly="true"
						value="#{beneficioController.selectedBeneficio.socio.nomeSocio}"
						styleClass="inputfield-readonly" />
					<p:spacer width="5px" />
					<p:commandButton icon="ui-icon-search" id="selectSocio"
						update=":frmContent:dlgSocio" process="@none"
						oncomplete="dlgSocio.show()" />

					<p:dialog id="dlgSocio" header="#{text.titDlgSocio}"
						appendToBody="false" widgetVar="dlgSocio" modal="false"
						resizable="false" styleClass="dlgSelect" showEffect="drop"
						hideEffect="drop">

						<p:dataTable id="grdSocio" var="socio"
							value="#{beneficioController.socioDataModel}"
							widgetVar="grdSocio" emptyMessage="#{text.grdEmpty}"
							selection="#{beneficioController.selectedSocio}" paginator="true"
							rows="10"
							paginatorAlwaysVisible="false" paginatorPosition="bottom"
							sortBy="#{socio.nomeSocio}"
							paginatorTemplate=" {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
							style="width:600px;" filterEvent="enter">
							<p:column selectionMode="single" style="width:18px" />
							<p:column id="colSocioNome" headerText="#{text.lblSocio}"
								sortBy="#{socio.nomeSocio}" filterBy="#{socio.nomeSocio}">
								<h:outputText value="#{socio.nomeSocio}" />
							</p:column>
							<f:facet name="footer">
								<p:commandButton value="#{text.btnConfirm}"
									oncomplete="dlgSocio.hide();"
									process=":frmContent:grdSocio"
									update=":frmContent:socio"
									actionListener="#{beneficioController.selectSocio}" />
								<p:commandButton value="#{text.btnCancel}" global="false"
									onclick="dlgSocio.hide();" />
							</f:facet>
						</p:dataTable>
					</p:dialog>
				</h:panelGroup>
				<p:message for="socio" />

				<h:outputLabel for="cod" value="#{text.lblBeneficioCodigo}" />
				<p:inputText id="cod" required="true" size="15" maxlength="10"
					value="#{beneficioController.selectedBeneficio.idBeneficio}"
					readonly="true" styleClass="inputfield-readonly" />
				<p:message for="cod" />

				<h:outputLabel for="tipo"	value="#{text.lblBeneficioTipo}" />
				<p:selectOneMenu id="tipo" effect="fade"
					style="width:150px;"
					value="#{beneficioController.selectedBeneficio.tipoBeneficio.id}">
					<f:selectItem itemLabel="#{text.lblUnselectCombo}" itemValue="" />
					<f:selectItems value="#{beneficioController.tipoBeneficioList}" var="tipoBeneficio"
								itemLabel="#{tipoBeneficio.descTipo}" itemValue="#{tipoBeneficio.id}" />
				</p:selectOneMenu>
				<p:message for="tipo" />

				<h:outputLabel for="data"
					value="#{text.lblBeneficioData}" />
				<p:calendar id="data" size="20" maxlength="10"
					navigator="true" pattern="dd/MM/yyyy" showOn="both"
					value="#{beneficioController.selectedBeneficio.dataBeneficio}" 
					required="true" requiredMessage="#{message.requiredBeneficioData}"/>
				<p:message for="data" />

				<h:outputLabel for="desc" value="#{text.lblBeneficioDesc}" />
				<p:inputText id="desc" required="true" size="50" maxlength="40"
					requiredMessage="#{message.requiredBeneficioDesc}"
					value="#{beneficioController.selectedBeneficio.descBeneficio}" />
				<p:message for="desc" />

				<h:outputLabel for="valor" value="#{text.lblBeneficioValor}" />
				<p:inputText id="valor" required="true" size="15" maxlength="20"
					requiredMessage="#{message.requiredBeneficioValor}"
					styleClass="inputTaxa"
					value="#{beneficioController.selectedBeneficio.valBeneficio}" />
				<p:message for="valor" />
				<h:outputScript>
					$(".inputTaxa").setMask({
	   	    			mask:"99.999999999999", 
		    			autoTab: false,
						maxLength: 14,
						type: 'reverse'
	    			});
				</h:outputScript>



			</h:panelGrid>



			<p:separator />


			<p:commandButton id="btnSave" value="#{text.btnSave}"
				icon="ui-icon-disk" update=":frmContent:fieldSetBeneficio"
				actionListener="#{beneficioController.saveBeneficio}"
				process=":frmContent:fieldSetBeneficio"/>
			<p:commandButton id="btnDelete" value="#{text.btnDelete}"
				icon="ui-icon-trash" onclick="dialogDelete.show()"
				binding="#{beneficioController.btnDelete}"
				disabled="#{sessionScope.idBeneficio == null}" global="false" />
			<p:confirmDialog id="dlgConfirmDelete" widgetVar="dialogDelete"
				closable="true" severity="info" appendToBody="true"
				header="#{text.dlgConfirm}" message="#{message.confirmDelete}"
				width="400">
				<p:commandButton id="btnConfirmDelete"
					action="#{beneficioController.deleteBeneficio}" immediate="true"
					value="#{text.btnConfirm}" icon="ui-icon-check"
					oncomplete="dialogDelete.hide(),tabView.select(0);"/>
				<p:commandButton id="btnDeclineDelete" onclick="dialogDelete.hide()"
					value="#{text.btnCancel}" icon="ui-icon-cancel" global="false" />
			</p:confirmDialog>

			<p:button id="btnBackBotton" value="#{text.btnBack}"
				outcome="/pages/beneficio/list.xhtml?selectedMenu=1" ajax="false" async="false"
				icon="ui-icon-arrowreturnthick-1-w" />

		</p:fieldset>


	</ui:define>
</ui:composition>
</html>